import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';
import { Layout, Menu } from 'antd';
import styles from './Navbar.scss';
import LocalStorage from '../../utils/localStorage';
import * as constants from '../../constants';
import wicologo2 from '../../assets/alogo.jpeg';
// import wicologo2 from '../../assets/wicologo2.png';

export default class Navbar extends Component {
  logout = () => {
    LocalStorage.remove(constants.FIELDS.USER_NAME);
    LocalStorage.remove(constants.FIELDS.TOKEN_NAME);
    LocalStorage.remove(constants.FIELDS.ORGANIZATION_ID);
    this.context.router.push('/login');
  }

  render() {
    const title = '智能无线';
    const username = LocalStorage.get(constants.FIELDS.USER_NAME);
    return (
      <Layout.Header className="header">

        <Menu
          theme="dark"
          mode="horizontal"
          defaultSelectedKeys={['2']}
          style={{ lineHeight: '64px' }}
        >
        <Menu.Item key="1">
          <img src={wicologo2} style={{paddingTop: "0px", width: "125px"}}/>
        </Menu.Item>
         <Menu.Item key="2">
           <Link to='/'>HOME</Link>
         </Menu.Item>
          {
            username ?
              <Menu.Item key="3">
                <div onClick={this.logout} >退出</div>
              </Menu.Item>
              :
              <Menu.Item key="4">
                <Link to='/login'>登录</Link>
              </Menu.Item>
          }
         <Menu.Item key="5">
         <span style={{paddingLeft:"400px", color: "#999"}}>
           亚玛芬全国连锁门店-WiFi嗅探大数据分析系统
           </span>
         </Menu.Item>

        </Menu>

      </Layout.Header>
    );
  }
}

Navbar.contextTypes = {
  router: PropTypes.object,
}
